package com.ekingstar.lss.commons.supper.utils.query.simple;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.ekingstar.lss.commons.exceptions.QueryUtilsException;
import com.ekingstar.lss.commons.supper.utils.query.LssOrder;

/**
 *	公司：金仕达多媒体
 *	作者：童弘成
 *	时间：2011-4-21 下午04:57:01
 *	描述：
 */
public class SimpleOrder implements LssOrder, Serializable {
	private static final long serialVersionUID = -7948047160032882545L;
	private Map<String, String> order;
	
	public SimpleOrder(){}
	
	public SimpleOrder(String order){
		if(order==null||"".equals(order)){
			throw new QueryUtilsException("排序字符串不能为空");
		}
		order=order.trim()+" 1";
		String temp=order.substring(0,order.indexOf(" "));
		this.order=new HashMap<String, String>();
		this.order.put("column", temp);
		if(order.split(" ")[1].indexOf("desc")!=-1){
			this.order.put("type", "desc");
		}else{
			this.order.put("type", "asc");
		}
	}
	public String getOrder() {
		return this.order.get("column");
	}

	public void setOrder(String column) {
		this.order.put("column", column);
	}
	
	public String getType() {
		return this.order.get("type");
	}
	
	public void setType(String type) {
		this.order.put("type",type);
	}

}
